
Free Online Find and Replace Text
Find and replace words or patterns in your text with match case, whole words, regular expressions and a live preview of every match.
Find and replace is one of the oldest and most useful text tools. You change every “colour” to “color” in a long text, swap a client name in a template, or clean up odd characters pasted from a web page. This version shows every match highlighted before you replace, supports regular expressions, and keeps one level of undo.
Basic find and replace
- Paste your text in the big box.
- Type what to find. Matches are highlighted at once in the preview, and a counter shows how many there are.
- Type the replacement. Leave it empty to delete every match.
- Press Replace all. If the result is wrong, press Undo last replace to restore the previous text.
By default the search ignores case, so “the”, “The” and “THE” all match. Tick “Match case” for exact letters. Tick “Whole words only” to avoid changing parts of other words: searching for “cat” in “concatenate” would hit the middle of the word, but with whole words on, only the standalone “cat” matches.
Regular expressions in plain words
A regular expression, often called regex, is a small pattern language for matching text. It looks hard, but a few pieces cover most needs.
| Pattern | Meaning | Example match |
|---|---|---|
colou?r |
The u is optional | color, colour |
\d+ |
One or more digits | 42, 2026 |
^\s+|\s+$ |
Spaces at the start or end of a line | Leading and trailing spaces |
(\w+) (\w+) |
Two words, captured | Use $2 $1 to swap them |
\s{2,} |
Two or more spaces | Doubled spaces |
Tick “Regular expression” to turn the pattern language on. In the replacement box, $1 and $2 insert what the first and second brackets captured. When regex is off, a dollar sign in the replacement is plain text, so you will not get surprises when replacing a price such as $5.
Walking through a real replacement
Load the sample with the example button and the box holds “Color is the American spelling. The colour red, the colour blue.” The pattern colou?r matches three words: Color, colour and colour. The preview highlights all three. Replace them with “shade” and you get “shade is the American spelling. The shade red, the shade blue.” For a more powerful job, search for (\w+) (\w+) and replace with $2 $1 to swap each pair of words. Always check the preview first, because patterns can match more than you expect.
Why this tool is safe to use with complex patterns
Some regex patterns, such as (a+)+$, can take an enormous amount of time on certain texts. This is called catastrophic backtracking, and in a simple tool it freezes the browser tab. Here, every search and replacement runs in a separate background worker with a time limit. If a pattern takes more than a couple of seconds, the worker is stopped and you see a message asking you to simplify the pattern. Your page stays responsive the whole time. An invalid pattern, such as an unclosed bracket, gives a plain-language error rather than a crash. Your text is treated as data and is never run as code.
Working carefully
A few habits make replacement safer. First, search before you replace, and read the highlighted matches in the preview. Second, replace in small steps when the job is complicated: do one pattern, check, then do the next. Third, keep the original text in another window or file until you are happy. Fourth, remember that the preview shows only the first twenty thousand characters of a very large text, although the replacement will still apply to everything, so look at the match counter as well as the picture. Finally, if a pattern is hard to read, write it down in plain words first, then translate it into regex.
Typical jobs
- Fix spelling variants across a long document.
- Fill in templates by replacing [NAME] with a real name.
- Clean copied text by removing double spaces or stray symbols.
- Reformat lists by replacing line breaks or commas.
- Rename items in a list of file names before using them elsewhere.
Common mistakes
- Replacing a short word without “Whole words only”.
- Forgetting that special characters such as the full stop and the dollar sign have meaning in regex mode. Turn regex off to search for them literally, or put a backslash before them.
- Replacing everything without looking at the match count.
- Not keeping a copy of the original. The undo only goes back one step.
- Using Replace all on code or data without checking edge cases.
Privacy and limits
All work happens in your browser and nothing is uploaded. The tool accepts up to a million characters and shows up to 2,000 matches in the preview. The regex flavour is the one your browser uses (JavaScript), with Unicode mode on, so some features from other languages, such as certain lookbehind or possessive forms, may differ. If a pattern works here but not in another program, the flavour is the usual reason.
Learn more patterns in the regex tester when it is live, practise text tidying in the Excel course and see Python for scripting larger jobs. For plain writing tools, the text case converter is a good companion.
Key takeaways
- Check the highlighted matches before you replace.
- Use Whole words only to avoid changing parts of words.
- Regex is powerful but needs care; use $1 and $2 for captured parts.
- Patterns run in a protected worker with a time limit.
Questions
How do I replace text with a regular expression?
Tick Regular expression, type your pattern in Find, and type the replacement. Use brackets to capture parts of a match and $1 or $2 in the replacement to insert them. For example, finding (\w+) (\w+) and replacing with $2 $1 swaps each pair of words. Check the highlighted preview first.
Why does a search for a symbol like the dollar sign act strangely?
In regular expression mode, symbols such as the dollar sign, full stop and brackets have special meanings. Switch regex off to search for them as plain text, or put a backslash before the symbol. With regex off, the replacement is also plain text, so a price such as $5 is inserted exactly as typed.
What does Whole words only do?
It makes the pattern match only when the text is not part of a longer word. Searching for cat finds the word cat but not concatenate or category. The check treats letters, digits and underscores as parts of a word, which matches how most people think of a whole word.
What happens if my pattern is too slow?
Searches and replacements run in a background worker with a time limit. If a pattern takes more than a couple of seconds, it is stopped and a message explains that it may be too complex. Your page stays usable and you can simplify the pattern. This protects against catastrophic backtracking.
Can I undo a replacement?
Yes, one step. Press Undo last replace to restore the text as it was before the latest Replace all. If you replace several times in a row, only the last change can be undone, so copy your text somewhere safe before doing a large or risky replacement.
